<template>
  <div class="all">
    <!--banner图-->
    <div class="banner_new"></div>
    <!--新闻列表-->
    <div class="new_lists">
      <div class="news_bank" v-for="(item,index) in data" @click="toInfoDetail(item.id)">
        <div class="bank_img" v-if="item.files">
          <img :src="_filterObj(item.files)"/>
        </div>
        <div class="bank_img" v-else>
          <img :src="imgUrl"/>
        </div>
        <div class="bank_content">
          <p class="ellipsi">{{item.title}}</p>
          <p v-html="$options.filters.deleteImgSting(item.content)" class="ellipsis"></p>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss">
  @import "~common/sass/mixin.scss";
  .all {
    width: 100%;
    height: 500px;
    margin: 0;
    padding: 0;
    .banner_new {
      width: 100%;
      height: 150px;
      background: url("../images/news_banner.jpg");
      background-size: 100% 150px;
    }
    .new_lists {
      width: 100%;
      margin-top: 10px;
      padding-bottom: 20%;
      .news_bank {
        width: 100%;
        height: 100px;
        border-bottom: 1px dotted #777777;
        padding-top: 10px;
        padding-bottom: 10px;
        .bank_img{
          width: 25%;
          height: 100%;
          float: left;
          margin-left: 5px;
          img{
            width: 100%;
            height: 100%;
          }
        }
        .bank_content{
          width:70%;
          float: left;
          margin-left: 5px;
          .ellipsi {
            @include ellipsis(1);
            font-size: 14px;
            line-height: 36px;
          }
          .ellipsis {
            @include ellipsis(1);
            font-size: 12px;
            margin-top: 10px;
          }
        }
      }
    }
  }

</style>
<script>
  import {getGroupData} from '../../http/article'
  import {filterObj} from '../../common/js/filterObj'

  export default {
    name: 'dishes',
    data() {
      return {
        data: [],
        total: 0,
        totalData: [],
        currentPage: 0,
        imgUrl: require('./images/new.png')
      }
    },
    created() {
      this._getGroupData('zixun')
    },
    methods: {
      _getGroupData(tag) {
        getGroupData(tag).then((res) => {
          this.data = res.data
        })
      },
      toInfoDetail(id) {
        this.$router.push('informationDetail/'+id)
      },
      handleCurrentChange(val) {
        this.currentPage = val - 1
      },
      _filterObj(obj) {
        return filterObj(obj)[0].url
      }
    },
    watch: {
      currentPage(newVal) {
        this.data = this.totalData.slice(newVal * 10, (newVal + 1) * 10)
      }
    }
  }
</script>
